package br.com.SAM.Bean;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceUnit;
import javax.persistence.Query;

import br.com.SAM.Interfaces.IPessoa;
import br.com.SAM.modelos.Pessoa;

@Stateless
public class PessoaBean extends GenericBean implements IPessoa{
	@PersistenceContext(unitName="sam")
	private EntityManager em;
	public Pessoa findByCpf(long cpf) {
		Query q = em.createNamedQuery("pessoa.findByCpf");
		q.setParameter("param", cpf);
		try{
			return (Pessoa) q.getSingleResult();
		}catch (NoResultException nre){
			return null;
		}
		
	}

}
